package cn.sdstudio.service.impl;


import cn.sdstudio.mapper.BaseMapperX;
import cn.sdstudio.model.BaseEntity;
import cn.sdstudio.service.BaseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collection;

public class BaseServiceImpl<M extends BaseMapperX<T>, T extends BaseEntity> extends ServiceImpl<M, T> implements BaseService<T> {

    @Autowired
    private BaseMapperX<T> baseMapper;

    @Override
    public T getByIdForUpdate(Long id) {
        return baseMapper.selectByIdForUpdate(id);
    }

    @Override
    public boolean saveBatch(Collection<T> list) {
        return baseMapper.batchInsert(list) == list.size();
    }
}
